home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks97
/
NewsTicker.sit
/
NewsTicker
/
source code
/
Internet Code
/
HTTPEndPoint.cp
< prev
next >
Wrap
Text File
|
1997-06-19
|
1KB
|
78 lines
/*------------------------------------------------------------------------------
#
# NewsTicker, my Hack for 1997
#
# HTTPEndPoint.cp - Slightly derived class for reading http/HTML files
#
------------------------------------------------------------------------------*/
#include "HTTPEndPoint.h"
#include "Idler.h"
#include "HTMLExtractor.h"
//
// Our constructor
//
HTTPEndPoint::HTTPEndPoint( HTMLExtractor* theHandler )
:OTPollEndPoint()
{
mfMyHandler = theHandler;
}
//
// Say we want to get the page
//
OSErr HTTPEndPoint::StartGettingFile(char* address, unsigned short portnum, Idler* theIdler)
{
Str255 TalkStr = "\pGET / HTTP/1.0\r\n\r\n";
OSErr io;
io = Open(*theIdler, address, portnum);
if (io==noErr)
{
SendData( *theIdler, &TalkStr[1], TalkStr[0]);
}
else
{
HandleShutdown();
}
return io;
}
OSErr HTTPEndPoint::StartGettingHeader(char* address, unsigned short portnum, Idler* theIdler)
{
Str255 TalkStr = "\pHEAD / HTTP/1.0\r\n\r\n";
OSErr io;
io = Open(*theIdler, address, portnum);
if (io==noErr)
{
SendData( *theIdler, &TalkStr[1], TalkStr[0]);
}
else
{
HandleShutdown();
}
return io;
}
//
// Send what we've just received to the outer worlds
//
void HTTPEndPoint::HandleData (char* thestring, short numchars)
{
if (mfMyHandler)
mfMyHandler->ReceiveString(thestring, numchars);
}
//
// Close The File
//
void HTTPEndPoint::HandleShutdown(void)
{
if (mfMyHandler)
mfMyHandler->Disconnect();
}